home comics writing pictures archive about

FormatHelper.cpp

Language: C++
Last Modified: 2022-09-10 5:29:28 PM UTC
File Size: 1363 bytes
http://www.penguinstew.ca/example/CodeFormater/FormatHelper.cpp
includeFormatHelperh
includePhpHelperh
includeTypeh
include<string>
include<regex>
std::stringFormatHelper::GetWordstd::stringlineintposstd::regexregEx
{
forunsignedintj=pos;j<linelength;j
{
ifstd::regex_matchlinesubstrj1regEx
{
returnlinesubstrposjpos;
}
}
return;
}
boolFormatHelper::IsMatchstd::stringlinestd::stringstrintlineStartPosstd::regexnextCharRegEx
{
intstrLength=strlength;
intlineLength=linelength;
iflineLengthlineStartPos<strLength
{
returnfalse;
}
iflinecomparelineStartPosstrLengthstr=0
{
returnfalse;
}
iflineLengthlineStartPos==strLength
{
returntrue;
}
ifstd::regex_matchlinesubstrlineStartPosstrLength1nextCharRegEx
{
returntrue;
}
returnfalse;
}
intFormatHelper::EscapeCountstd::stringlinestd::stringescapeintlineStartPos
{
intescapeLength=escapelength;
intescapeCount=0;
ifescapeLength==0
{
returnescapeCount;
}
Loopbackfromstart
forunsignedinti=lineStartPosescapeLength;i>=0;i=escapeLength{
iflinecompareiescapeLengthescape==0
{
escapeCount;
}
else{
break;
}
}
returnescapeCount;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71